import vue from '@vitejs/plugin-vue'
import Inspect from 'vite-plugin-inspect'

import createAutoImport from './auto-import'
import createComponents from './components'
import createIcon from './icons'
import createSvgIcon from './svg-icon'
import createCompression from './compression'
import createSetupExtend from './setup-extend'
import createVisualizer from './visualizer'
import createProgress from './progress'
import createImageMin from './imagemin'
import createHtml from './vite-plugin-html'

export default function createVitePlugins(viteEnv, isBuild = false) {
    const vitePlugins = [vue(), Inspect()]
    vitePlugins.push(createAutoImport())
    vitePlugins.push(createComponents())
    // @ts-ignore
    vitePlugins.push(createIcon())
    // @ts-ignore
    vitePlugins.push(createProgress())
    // @ts-ignore
    vitePlugins.push(createSetupExtend())
    // vitePlugins.push(createVisualizer())
    vitePlugins.push(createSvgIcon(isBuild))
    vitePlugins.push(createImageMin())
    vitePlugins.push(createHtml(viteEnv))
    isBuild && vitePlugins.push(...createCompression(viteEnv))
    return vitePlugins
}
